package com.shop.admin.controller.Admin;

import com.shop.entity.dto.AdminImages.AdminImagesListDto;
import com.shop.entity.dto.AdminImages.AdminImagesRemoveDto;
import com.shop.admin.service.ImagesService;
import com.shop.utils.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/images")
public class AdminImagesController {

    @Autowired
    private ImagesService imagesService;

    @PostMapping("save_images")
    public Result saveImages(@RequestParam("file") MultipartFile file,
                             @RequestParam("imagesName") String imageName){
        log.info("后台管理-添加图片素材");
        return imagesService.uploadPicture(file,imageName);
    }

    @PostMapping("get_wares_images_list")
    public Result getWaresImagesList(@RequestBody AdminImagesListDto dto){
        log.info("后台管理-图片素材列表");
        return imagesService.getWaresImagesList(dto);
    }
    @PostMapping("remove_wares_images")
    public Result removeWaresImages(@RequestBody AdminImagesRemoveDto dto){
        log.info("后台管理-删除图片素材");
        return imagesService.removeWaresImages(dto);
    }

}
